package com.wnzt.baszh.service.impl;

import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleIfStatement.Else;
import com.wnzt.baszh.dao.IMedicalShootDao;
import com.wnzt.baszh.dao.ISystemMaintenDao;
import com.wnzt.baszh.dao.IUtilDao;
import com.wnzt.baszh.entity.Tsysuser;
import com.wnzt.baszh.service.IMedicalShootService;
import com.wnzt.baszh.util.common.PageHelper;
import com.wnzt.baszh.util.common.TextMarkService;
/**
 * 数字化系统拍摄管理service接口实现类
 * @author dqw
 * @date 2017-3-14
 */
@Repository
public class MedicalShootService implements IMedicalShootService{
	
	@Autowired
	private IUtilDao utilDao;
	
	@Autowired
	private IMedicalShootDao medicalShootDao;
	
	@Autowired
    private ISystemMaintenDao iSystemMaintenDao; 

	@Override
	public PageHelper getShootData(Map<String, Object> map) {
		PageHelper page = medicalShootDao.getShootData(map);
		return page;
	}

	@Override
	public PageHelper getAuditData(Map<String, Object> map) {
		PageHelper page = medicalShootDao.getAuditData(map);
		return page;
	}

	@Override
	public boolean savePicture(Map<String, Object> map) {
		boolean flag = medicalShootDao.savePicture(map);
		return flag;
	}

	@Override
	public List<Map<String, Object>> getTree(Map<String, Object> paramMap) {
		List<Map<String, Object>> list = medicalShootDao.getTree(paramMap);
		return list;
	}

/*	@Override
	public void update(String fprn, int ftimes) {
		this.medicalShootDao.update(fprn,ftimes);
		
	}*/

	@Override
	public Map<String, Object> auditOperation(Map<String, Object> map) {
		Map<String, Object> flag = medicalShootDao.auditOperation(map);
		return flag;
	}

	/*@Override
	public void updateDecode(String fprn, int ftimes, String number) {
		this.medicalShootDao.updateDecode(fprn,ftimes,number);
		
	}*/

	@Override
	public Map<String, Object> errorReport(Map<String, Object> map) {
		Map<String, Object> result = medicalShootDao.errorReport(map);
		return result;
	}

	@Override
	public List<Map<String, Object>> getReasonRecord(Map<String, Object> map) {
		List<Map<String, Object>> list = medicalShootDao.getReasonRecord(map);
		return list;
	}

	@Override
	public List<Map<String, Object>> getListOptions() {
		List<Map<String, Object>> list = medicalShootDao.getListOptions();
		return list;
	}

	@Override
	public boolean appendImg(Map<String, Object> map) {
		boolean flag = medicalShootDao.appendImg(map);
		return flag;
	}

	@Override
	public boolean repeatShoot(Map<String, Object> map) {
		boolean result = medicalShootDao.repeatShoot(map);
		return result;
	}

	@Override
	public boolean removePicture(Map<String, Object> map) {
		boolean result = medicalShootDao.removePicture(map);
		return result;
	}

	@Override
	public PageHelper getQuestionData(Map<String, Object> map) {
		PageHelper page = medicalShootDao.getQuestionData(map);
		return page;
	}

	@Override
	public List getDept() {
		List<Map<String, Object>> list = utilDao.getDept();
		return list;
	}

	@Override
	public List<Map<String, Object>> getZzDoc() {
		List<Map<String, Object>> list = utilDao.getZzDoc();
		return list;
	}

	@Override
	public List<Map<String, Object>> getCategory() {
		List<Map<String, Object>> list = utilDao.getCategory();
		return list;
	}

	@Override
	public PageHelper PreviewListSearch(Map<String, Object> map) {
		PageHelper page = medicalShootDao.PreviewListSearch(map);
		return page;
	}

	@Override
	public List<Map<String, Object>> getJB() {
		List<Map<String, Object>> list = utilDao.getJB();
		return list;
	}

	@Override
	public Object getBtnPermision(Tsysuser user, String tabtext) {
		return utilDao.getBtnPermision(user,tabtext);
	}

    @Override
    public void watermark(Tsysuser user, File image, String imageFileName, String realUploadPath) {
        
        List<Map<String, Object>> params = iSystemMaintenDao.CheckWatermark();  // 查询水印参数
        String text = medicalShootDao.watermarkUUID(user.getFcode());  // 水印文本
        
        float alpha = 0.3f;  // 透明度
        String fontName = "宋体";  // 字体
        int fontSize = 26;   // 字体大小
        int fontStyle = 0;  // 加粗  1为加粗
        String colorHex = "";
        
        int fontValue = 0;
        if (!params.isEmpty()) {
            fontValue = (Integer) params.get(0).get("FZT");  // 字体
            fontSize = (Integer) params.get(0).get("FDX");  // 字体大小
            fontStyle = (Integer) params.get(0).get("FJC");  // 加粗  1为加粗
            colorHex = (String) params.get(0).get("FYS");   // 颜色
            alpha = (float) ((Integer) params.get(0).get("FTMD") * .01);  // 透明度
        }
        
        if (fontValue == 1) {
            fontName = "黑体";
        } else if (fontValue == 2) {
            fontName = "微软雅黑";
        }
        
        Font font = new Font(fontName, fontStyle, fontSize);
        Color color = TextMarkService.toColorFromString(colorHex);
        TextMarkService.watermark(text, fontSize, font, color, alpha, image, imageFileName, realUploadPath);
    }

	@Override
	public Map<String, Object> transfer(Map<String, Object> map) {
		Map<String, Object> resultMap = medicalShootDao.transfer(map);
		return resultMap;
	}

	@Override
	public Map<String, Object> auditFail(Map<String, Object> map) {
		Map<String, Object> result = medicalShootDao.auditFail(map);
		return result;
	}

	@Override
	public List getSqmd() {
		List<Map<String, Object>> list = utilDao.getSqmd();
		return list;
	}

	@Override
	public List<Map<String, Object>> getBagdmx(Map<String, Object> params) {
		return medicalShootDao.getBagdmx(params);
	}
	
	

}
